﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace CPPEI.Coolzon.UI
{
    public class ControlPart : Part
    {
        //static ControlPart()
        //{
        //    DefaultStyleKeyProperty.OverrideMetadata(typeof(ControlPart), new FrameworkPropertyMetadata(typeof(ControlPart)));
        //}

        public Metadata.Part PartMetadata
        {
            get
            {
                return (Metadata.Part)Metadata;
            }
            set
            {
                Metadata = value;
            }
        }
        
        /// <summary>
        /// 设置组件元数据
        /// </summary>
        /// <param name="partMetadata"></param>
        public void SetPartMetadata(Metadata.Part partMetadata)
        {
            this.PartMetadata = partMetadata;
            
            // 显示查询按钮
            if (this.PartMetadata.IsShowQueryPanel)
            {
                Button btnQuery = new Button();
                btnQuery.Content = "Q";
                this.AddToolbarButton(btnQuery);
                btnQuery.Click += btnQuery_Click;
            }
        }

        [Obsolete("bug")]
        void btnQuery_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            //EventBus.Instance.ShowQueryPanel(this, this.PartMetadata);
        }
    }
}
